package handler

import (
	"net/http"

	"laundry-service/app/client/internal/logic"
	"laundry-service/app/client/internal/svc"

	"github.com/zeromicro/go-zero/rest/httpx"
)

type Body struct {
	Code int    `json:"code"`
	Msg  string `json:"msg"`
}

func WxRefundCallbackHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
	return func(w http.ResponseWriter, r *http.Request) {
		l := logic.NewWxRefundCallbackLogic(r.Context(), svcCtx, r)
		_, err := l.WxRefundCallback()
		var body Body

		if err != nil {
			body.Code = 400
			body.Msg = err.Error()
		} else {
			body.Code = 200
			body.Msg = "success"
		}
		httpx.OkJson(w, body)
	}
}
